import 'package:flutter/material.dart';
import 'package:flutter2/colors.dart';
import 'package:flutter2/widget/base/normal_text.dart';
import 'package:get/get.dart';

class TitleBar {
  TitleBar._();

  static AppBar buildAppBar({
    bool showBack = true,
    String? title,
    Color? titleColor,
    double? titleSize,
    VoidCallback? back,
    Widget? flexibleSpace,
    Color? backgroundColor,
    FontWeight? fontWeight,
  }) {
    return AppBar(
      scrolledUnderElevation: 0,
      elevation: 0,
      shadowColor: Colors.transparent,
      backgroundColor: backgroundColor ?? Colors.white,
      centerTitle: true,
      title: NormalText(
        text: title,
        fontSize: titleSize ?? 18,
        fontColor: titleColor ?? mainText,
        fontWeight: fontWeight,
      ),
      leading: showBack
          ? IconButton(
              onPressed: back ?? Get.back,
              icon: Icon(
                Icons.arrow_back_rounded,
                color: mainText,
              ),
            )
          : null,
      flexibleSpace: flexibleSpace,
    );
  }
}
